package com.wx.tgp.designpattern.decorativePattern;

import com.wx.tgp.designpattern.decorativePattern.PresonDecorative.KuZiDecorative;
import com.wx.tgp.designpattern.decorativePattern.PresonDecorative.MaoZiDecorative;
import com.wx.tgp.designpattern.decorativePattern.PresonDecorative.Person;
import com.wx.tgp.designpattern.decorativePattern.PresonDecorative.XiZhuangDecorative;
import com.wx.tgp.designpattern.decorativePattern.decorative.ContreteComponent;
import com.wx.tgp.designpattern.decorativePattern.decorative.ContreteDecorativeA;
import com.wx.tgp.designpattern.decorativePattern.decorative.ContreteDecorativeB;

/**
 * 装饰模式
 */
public class Client {


    public static void main(String args[]){
        // 官方提供的简易案例
//        ContreteComponent c = new ContreteComponent();
//        ContreteDecorativeA cA = new ContreteDecorativeA();
//        ContreteDecorativeB cB = new ContreteDecorativeB();
//        cA.setComponent(c);
//        cB.setComponent(cA);
//        cB.Operation();
        // 自己写的demo
        /**
         * 如果要想增加装饰，只要
         * 增加类型的MaoZiDecorative，装饰对象即可，
         * 这样在代码中把这些装饰对象随意组合，即可。
         */
        Person xiaoMing = new Person("小明");
        KuZiDecorative kuZi = new KuZiDecorative();
        MaoZiDecorative maoZi = new MaoZiDecorative();
        XiZhuangDecorative xiZ = new XiZhuangDecorative();

        kuZi.setDecorative(xiaoMing); // 这个方法代表是给哪一个对象进行增加行为
        xiZ.setDecorative(kuZi);     // 这些方法是给上面哪一个对象增加哪些行为
        // ......
        xiZ.Decorative();


    }
}
